﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using HR.Appointments.Service;

public partial class booking : UserPage
{
    #region Events
    protected void Page_Load(object sender, EventArgs e)
    {
        _imgConfirm.Visible = IsLoggedIn;
        if (!IsPostBack)
        {
            ListActivities();
            ListWorkstations();

            CompanyEntity company = Facade.Anonymous().GetCompanyInstance(GetCompanyIdFromCookie());
            _lblDescription.Visible = company.Description.Length > 0;
            _lblDescription.Text = company.Description;
        }
    }

    protected void _btnFindTime_Click(object sender, EventArgs e)
    {
        string activityId = _ddlAction.SelectedValue.ToString();
        string workstationId = _ddlWorkstation.SelectedValue.ToString();
        Server.Transfer("~/VacantSlots.aspx?"
            + "ActivityId=" + activityId
            + "&WorkstationId=" + workstationId,true);
    }
    #endregion

    #region Link Transfer
    protected void _ibmHomePage_Click(object sender, ImageClickEventArgs e)
	{
        if (!IsPostBack || (e.X != 0 && e.Y != 0))
        {
            Server.Transfer("~/Company.aspx",true);
        }
	}
	protected void _lbtnCompany_Click(object sender, EventArgs e)
	{
		Server.Transfer("~/Company.aspx", true);
    }
    #endregion

    #region Private List Methods
    private void ListActivities()
    {
        _ddlAction.DataSource = Facade.Anonymous().GetActivities(GetCompanyIdFromCookie());
        _ddlAction.DataBind();
    }

    protected void ListWorkstations()
    {
        _ddlWorkstation.DataSource = Facade.Anonymous().GetWorkstations(GetCompanyIdFromCookie());
        _ddlWorkstation.DataBind();
    }
    #endregion
}
